//////////////////////////////////////////////////////////////////////////////////
//	Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef _SCRIPT_GENERATOR_YG_H__
#define _SCRIPT_GENERATOR_YG_H__

#include "def.h"

class CScriptGenerator
{
public:
	CScriptGenerator(class CConfigData& data);
	~CScriptGenerator(void);

	void								SetSciptType(bool bXML) { m_bXML = bXML; }

	wxString							GenerateNATOptScript();
	wxString							GenerateTCPScript();
	wxString							GenerateP2PScript();
	wxString							GenerateWWWScript();
	wxString							GenerateICMPScript();


	wxString							GenerateMACBlockScript(const MACBLOCK& lstWhite, const MACBLOCK& lstBlack, bool bLog);
	wxString							GenerateAdvancedOptScript( const STRINGPAIRLIST& lst );
	wxString							GeneratePortForwardScript( const PORTFORWARDLIST& lst );
	static wxString						GenerateStartUpScript();

	wxString							GenerateProcKillScript(const TEXTLIST& lst);
	wxString							GenerateModUnloadScript(const TEXTLIST& lst);
	wxString							GenerateSyslogConfigScript(const wxString& strIP, long lPort, long lLogLevel);

	typedef struct tagScrParams  
	{
		wxString	file;
		wxString	val;
	}SRCVAL;

protected:
	static wxString GetPathFromName(const wxString& strName);
	static wxString GetProtoString( cPortFrorwardProto proto );
	static wxString BuildPFRule(const PORTFORWARDRULE& rule, cPortFrorwardProto proto);

	wxString GenerateScript( SRCVAL vals[], size_t tSize );
	wxString GenerateMACBlockScriptXML(const MACBLOCK& lstWhite, const MACBLOCK& lstBlack, bool bLog);
	wxString GeneratePortForwardScriptXML(const PORTFORWARDLIST& lst );

private:
	wxString m_strNatChainName;
	wxString m_strPortForwardChainName;
	wxString m_strMACBlockChainName;

	bool	m_bXML;
};

#endif //_SCRIPT_GENERATOR_YG_H__
